<template>
  <section>
      <div class="model query">
      <img :src="IMGBASE64.LISHITONGZHI2X" class="pink">
      <span class="title">历史通知</span>
      <div class="kong"></div>
      <template>
        <el-table :data="tablemsg" style="width: 100%">
          <el-table-column prop="id" label="#" align="center"></el-table-column>
          <el-table-column prop="content" label="通知内容" :show-overflow-tooltip='true' align="center"></el-table-column>
          <el-table-column prop="noticeTypeName" label="类型" align="center"></el-table-column>
          <el-table-column prop="time" label="发布时间" align="center"></el-table-column>
          <el-table-column label="操作" align="center">
            <template scope="scope">
              <el-button type="text" size="small">重发</el-button>
              <el-button type="text" size="small" @click="delectData(scope)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          v-show="paging"
          @current-change="handleCurrentChange"
          :page-size="20"
          layout="prev, pager, next, jumper"
          :total="total"
          class="pull-right">
        </el-pagination>
      </template>
    </div>
  </section>
</template>

<script>
export default {
  data () {
    return {
      total: 0,
      page: 1,
      paging: true,
      tablemsg: [],
      id: 0
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    handleCurrentChange (val) {
      this.page = val
      this.getData()
    },
    getData () {
      // let _cookie = document.cookie.split(';')
      // let _cookieArray = []
      // _cookie.forEach(v => {
      //   let _d = v.split('=')
      //   _cookieArray.push({
      //     key: _d[0],
      //     value: _d[1]
      //   })
      // })
      this.$http.post(this._httpUrl + 'homeSchool/notice/historyNotices', {page: (this.page), rows: 20}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.tablemsg = response.data.data.content
          this.total = response.data.data.total
          console.log(this.tablemsg)
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    delectData (scope) {
      // let _cookie = document.cookie.split(';')
      // let _cookieArray = []
      // _cookie.forEach(v => {
      //   let _d = v.split('=')
      //   _cookieArray.push({
      //     key: _d[0],
      //     value: _d[1]
      //   })
      // })
      this.id = scope.row.id
      this.$http.get(this._httpUrl + 'homeSchool/notice/historyNotices/del?noticeId=' + this.id, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.getData()
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
@import '/static/css/all-use.css';
  .retrieval{
    .body{
      span{
        margin-left: 4%;
      }
      span:first-child{
        margin-left: 0;
      }
      .right{
        float: right;
        margin-right: 5%;
      }
    }
    .select{
      width: 10%;
      border: 0;
      border-bottom: 1px solid #D7D7D7;
    }
    .middle{
      width: 25%;
      display: inline-block;
      margin-left: 10%;
      &-text{
        width: 58%;
        border: 0;
        border-bottom: 1px solid #D7D7D7;
      }
    }
  }
  .el-table
  {
    .cell
     {
       height: 24px;
     }
  }

</style>
